package com.distributedDataBase.controller;

import com.distributedDataBase.pojo.Product;
import com.distributedDataBase.pojo.Result;
import com.distributedDataBase.service.ProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping
    public Result index(String name, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "2") Integer pageSize){
        PageInfo<Product> pageInfo = productService.page(name,pageNum,pageSize);

        return new Result("200","首页数据加载ok",pageInfo);
    }
}
